package Observer;

import java.util.ArrayList;
import java.util.Observable;

/**
 * 该类实现主题接口这样我们可以向观察者推送消息
 */
public class WeatherData extends Observable {
    private ArrayList observers;
    private float temperature;
    private float humidity;
    private float pressure;

    public WeatherData() {
        this.observers = new ArrayList();
    }




    public void measurementsChanged() {
      setChanged();
      notifyObservers();
    }

    /**
     *
     * @param temperature  温度
     * @param humidity    湿度
     * @param pressure   压力
     */
    public void setMeasurements(float temperature,float humidity,float pressure) {
        this.temperature=temperature;
        this.humidity=humidity;
        this.pressure=pressure;
        measurementsChanged();
    }

    public ArrayList getObservers() {
        return observers;
    }

    public void setObservers(ArrayList observers) {
        this.observers = observers;
    }

    public float getTemperature() {
        return temperature;
    }

    public void setTemperature(float temperature) {
        this.temperature = temperature;
    }

    public float getHumidity() {
        return humidity;
    }

    public void setHumidity(float humidity) {
        this.humidity = humidity;
    }

    public float getPressure() {
        return pressure;
    }

    public void setPressure(float pressure) {
        this.pressure = pressure;
    }
}
